package com.sist.ocs.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SenderConfig {

    @Bean(name = "mydirectq")
    public Queue mydirectQueue() {
        return new Queue("myDirectQue");
    }

    @Bean(name = "mydirectconfirmq")
    public Queue mydirectConfirmQueue() {
        return new Queue("myDirectConfQue");
    }

    @Bean(name = "mytopicq")
    public Queue myTopicQueue() {
        return new Queue("mytopicQue");
    }

    @Bean(name = "myfanoutA")
    public Queue myFanoutQueueA() {
        return new Queue("myfanoutQueA");
    }

    @Bean(name = "myfanoutB")
    public Queue myFanoutQueueB() {
        return new Queue("myfanoutQueB");
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("mydirectExchage");
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("mytopicExchange");
    }

    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("myfanoutExchange");
    }

    @Bean
    public Binding bindingDirectExchage(@Qualifier("mydirectconfirmq") Queue queue, DirectExchange directExchange) {
        return BindingBuilder.bind(queue).to(directExchange).with("myDirectConfQue");
    }

    @Bean
    public Binding bindingTopicExchange(@Qualifier("mytopicq") Queue queue, TopicExchange topicExchange) {
        return BindingBuilder.bind(queue).to(topicExchange).with("topic.*");
    }

    @Bean
    public Binding bindingFanoutExchangeA(@Qualifier("myfanoutA") Queue queue, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(queue).to(fanoutExchange);
    }

    @Bean
    public Binding bindingFanoutExchangeB(@Qualifier("myfanoutB") Queue queue, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(queue).to(fanoutExchange);
    }
}
